﻿

//================= 常量 ========================

var CTIList = new Array();  

CTIList[0] = "CIC";
CTIList[1] = "Infobird";
CTIList[2] = "CIC 3.0";
CTIList[3] = "AvayaCCE";



var QueueType = "9"; // Queue Types: Station=3, User=9, Wrkgrp=10, Line=15  
//var isConnect =false;


var SoftPhoneEventID = new Object(); 
SoftPhoneEventID["Login"] = "10000"; 	         
SoftPhoneEventID["NotReady"] = "10001"; 	            
SoftPhoneEventID["Available"] = "10002"; 	             
SoftPhoneEventID["OtherWork"] = "10003"; 	          
SoftPhoneEventID["OtherStatus"] = "10004"; 	        
SoftPhoneEventID["Logout"] = "10005"; 	                

SoftPhoneEventID["RingingI"] = "20000";  	           
SoftPhoneEventID["RingingE"] = "20001";  	            
SoftPhoneEventID["Dialing"] = "20002";                  
SoftPhoneEventID["AnsweredI"] = "20003";                 	
SoftPhoneEventID["AnsweredE"] = "20004"; 

SoftPhoneEventID["Hold"] = "20005";          
SoftPhoneEventID["ConnectI"] = "20020";

SoftPhoneEventID["InitiateTransferConference"] = "20006";
SoftPhoneEventID["Conferenced"] = "20007";              

SoftPhoneEventID["HangupInternal"] = "20008";            
SoftPhoneEventID["HangupInboundUnCall"] = "20009";       	
SoftPhoneEventID["HangupOutboundUnCall"] = "20010";     

SoftPhoneEventID["ACWIn"] = "20011";                    
SoftPhoneEventID["ACWOut"] = "20012";                   

SoftPhoneEventID["Mute"] = "21001";                  
SoftPhoneEventID["GetRecordInfo"] = "21002";    
        
SoftPhoneEventID["TransferConferenceTalkingThird"] = "21003";
SoftPhoneEventID["Dial_UserBusy"] = "21004";
SoftPhoneEventID["Monitor"] = "21005"; 	
SoftPhoneEventID["Retrieved"] = "21006"; 
//SoftPhoneEventID["BothHolding"] = "21006"; 	
//SoftPhoneEventID["LogFailed"] = "21007"; 	
//SoftPhoneEventID["TransferConferenceTalkingThird"] = "20011";//二步 转接、会议:连接
SoftPhoneEventID["HangupTalkingThird"] = "21007"; 	




var EventType = new Object(); 

//EventType["ENTAgentLoggedIn"] = "20001"; 	
//EventType["ENTAgentLoggedOut"] = "20002"; 	
//EventType["ENTAgentState"] = "20003"; 	
//EventType["ENTAlerting"] = "20004"; 	
//EventType["ENTAnswered"] = "20005"; 	
//EventType["ENTRelease"] = "20006"; 	
//EventType["ENTDialing"] = "20007"; 	
//EventType["ENTFailed"] = "20008"; 	


EventType["CCEConnectEvent"] = "20000";
EventType["CCEDisconnectEvent"] = "20001";
EventType["CCELoginEvent"] = "20002";
EventType["CCELogoutEvent"] = "20003";
EventType["CCEAvailable"] = "20004";
EventType["CCENotReady"] = "20005";
EventType["CCEOtherWork"] = "20006";
EventType["CCEAfterCallWork"] = "20007";
EventType["CCEACWIn"] = "20008";
EventType["CCEACWOut"] = "20009";

EventType["CCECallAlertingEvent"] = "20101";
EventType["CCECallDialEvent"] = "20102";
EventType["CCECallAnswerEvent"] = "20103";
EventType["CCECallHangUpEvent"] = "20104";
EventType["CCEHold"] = "20105";
EventType["CCEInitiateTransferConference"] = "20106";
EventType["CCEConferenced"] = "20107";
EventType["CCEMute"] = "20108";
EventType["CCEDelivered"] = "20201";



//====================================

EventType["NoLogon"] = "30001"; 	
EventType["Waiting"] = "30002"; 	
EventType["Parking"] = "30003"; 	
EventType["Ringing"] = "30004"; 	
EventType["Dialing"] = "30005"; 	
EventType["Talking"] = "30006"; 	
EventType["Holding"] = "30007"; 	
EventType["Held"] = "30008"; 	
EventType["DialingThird"] = "30009"; 	
EventType["TalkingThird"] = "30010"; 	
EventType["TalkingThirdPassivity"] = "30011"; 	
EventType["ConfPreside"] = "30012"; 	
EventType["Conf"] = "30013"; 	
EventType["Monitor"] = "30014"; 	
EventType["BothHolding"] = "30015"; 	
EventType["InPending"] = "30016"; 	
EventType["Processing"] = "30017"; 	
EventType["Dial_UserBusy"] = "30018"; 	
EventType["LogFailed"] = "30019"; 	


//====================================


EventType["Alerting"] = "1001"; 	
EventType["Dialing"] = "1002"; 	            
EventType["Connected"] = "1003"; 	            
EventType["Disconnected"] = "1004"; 	            
EventType["Hold"] = "1005";      
EventType["InitiateTransferConference"] = "1006";      
EventType["Conferenced"] = "1007"; 
EventType["GetRecordInfo"] = "2001"; 	


 

//====================================


EventType["NotReady"] = "10001"; 	            
EventType["Available"] = "10002"; 	           
EventType["OtherWork"] = "10003"; 	          
EventType["AfterCallWork"] = "10004"; 	        
EventType["Logout"] = "10005"; 	                  

EventType["RingingI"] = "10100";  	           
EventType["RingingE"] = "10101";  	            
EventType["Dialing"] = "10102";                  
EventType["AnsweredI"] = "10103";                 	
EventType["AnsweredE"] = "10104";                
EventType["ACWIn"] = "10105";                      
EventType["ACWOut"] = "10115";                   

EventType["HangupInternal"] = "10106";            
EventType["HangupInboundUnCall"] = "10107";       	
EventType["HangupOutboundUnCall"] = "10108";   

EventType["InitiateTransferConference"] = "10111";
EventType["Conferenced"] = "10112";              
EventType["GetRecordInfo"] = "10113";   

EventType["ctmpEK_NotReady"] = 203;
EventType["ctmpEK_Ready"] = 204;
EventType["ctmpEK_OtherWork"] = 205;           
EventType["ctmpEK_AfterCallWork"] = 206;
EventType["ctmpEK_BackInService"] = 23;			
EventType["ctmpEK_OutOfService"] = 24;				/* CSTA2 */
EventType["ctmpEK_LoggedOn"] = 201;
EventType["ctmpEK_LoggedOff"] = 202;

EventType["ctmpEK_Delivered"] = 4;              
EventType["ctmpEK_ServiceInitated"] = 13;      
EventType["ctmpEK_Established"] = 6;              
EventType["ctmpEK_ConnectionCleared"] = 3;      
EventType["ctmpEK_CallCleared"] = 1;         
EventType["ctmpEK_Held"] = 8;                  
EventType["ctmpEK_Retrieved"] = 12;         
EventType["ctmpEK_Confernced"] = 2;           
EventType["ctmpEC_Consultation"] = 37; 

EventType["ctmpEK_Diverted"] = 5;
EventType["ctmpEK_Established"] = 6;
EventType["ctmpEK_Failed"] = 7;
EventType["ctmpEK_NetworkReached"] = 9;
EventType["ctmpEK_Originated"] = 10;
EventType["ctmpEK_Queued"] = 11;
EventType["ctmpEK_Transferred"] = 14;
EventType["ctmpEK_eDiverted"] = 15;
EventType["ctmpEK_CallInformation"] = 101;
EventType["ctmpEK_DoNotDisturb"] = 102;
EventType["ctmpEK_Forwarding"] = 103;
EventType["ctmpEK_MessageWaiting"] = 104;
EventType["ctmpEK_AutoAnswer"] = 105;				/* CSTA2 */
EventType["ctmpEK_MicrophoneMute"] = 106;			/* CSTA2 */
EventType["ctmpEK_SpeakerMute"] = 107;				/* CSTA2 */
EventType["ctmpEK_SpeakerVolume"] = 108;				/* CSTA2 */
EventType["ctmpEK_eLoggedOn"] = 207;
EventType["ctmpEK_eLoggedOff"] = 208;
EventType["ctmpEK_eNotReady"] = 209;
EventType["ctmpEK_eReady"] = 210;
EventType["ctmpEK_Private"] = 25;					/* CSTA2 */
EventType["ctmpEK_VoiceUnitPlay"] = 41;				/* CSTA2 */
EventType["ctmpEK_VoiceUnitRecord"] = 42;			/* CSTA2 */
EventType["ctmpEK_VoiceUnitReview"] = 43;			/* CSTA2 */
EventType["ctmpEK_VoiceUnitStop"] = 44;				/* CSTA2 */
EventType["ctmpEK_VoiceUnitSuspendPlay"] = 45;		/* CSTA2 */
EventType["ctmpEK_VoiceUnitSuspendRecord"] = 46;		/* CSTA2 */
EventType["ctmpEK_VoiceUnitAttributeChange"] = 47;	/* CSTA2 */
EventType["ctmpEK_MonitorEnded"] = 61;				/* ASAI  */
EventType["ctmpEK_PrivateStatus"] = 63; 				/* ASAI  */
EventType["ctmpEK_SysStat"] = 65; 					/* ASAI  */
EventType["ctmpEK_SysStatEnded"] = 66; 				/* ASAI  */
EventType["ctmpEK_RouteRegisterAbort"] = 71; 		/* ASAI  */
EventType["ctmpEK_RouteRequest"] = 110; 				/* ASAI  */
EventType["ctmpEK_RouteEnd"] = 111; 					/* ASAI  */
EventType["ctmpEK_CCSEDisConnect"] = 250;   
EventType["ctmpEK_CCSEConnect"] = 251;				
EventType["ctmpEK_CCSEFail"] = 995;					// 2001/01/29 sbkyun
EventType["ctmpEK_CCSELinkFailPbx"] = 996;			// 2001/01/29 sbkyun  //ASAI惯积
EventType["ctmpEK_CCSENoActPbx"] = 997;				// 2001/01/29 sbkyun  //ASAI惯积
EventType["ctmpEK_CCSERecovery"] = 998; 				// 2001/01/29 sbkyun  //ASAI惯积
EventType["ctmpEK_CCSEDown"] = 999;					// CTMP Down sbkyun - 2001/01/29	/* for CCSE Down by dwlim 990127 req kcpark */
EventType["ctmpEK_Popup"] = 254;				// CTMP Oubound PopupEvent





var AgentStateType = new Object(); 

AgentStateType["ccpLoggingIn"] = 0; 	
AgentStateType["ccpLoggedOut"] = 20; 

AgentStateType["ccpIdle"] = 1; 	
AgentStateType["ccpNotReady"] = 5; 	
AgentStateType["ccpParked"] = 25; 	

AgentStateType["ccpDialing"] = 10; 	
AgentStateType["ccpRinging"] = 18; 	
AgentStateType["ccpActive"] = 2; 	
AgentStateType["ccpActiveinternal"] = 14; 	
AgentStateType["ccpWrapup"] = 4;

AgentStateType["ccpHeld"] = 6; 	
AgentStateType["ccpConsulting"] = 11; 	
AgentStateType["ccpActivedial"] = 13; 	
AgentStateType["ccpConferenced"] = 12; 	

AgentStateType["NextCall"] = 101; 	
AgentStateType["HangupInternal"] = 102; 	
AgentStateType["HangupInboundUnCall"] = 103; 	
AgentStateType["HangupOutboundUnCall"] = 104; 	

AgentStateType["Available"] = 2101;
AgentStateType["NotReady"] = 2102;
AgentStateType["OtherWork"] = 2103;
AgentStateType["AfterCallWork"] = 2104;
AgentStateType["OperationEnd"] = 2105;
AgentStateType["SetStatus"] = 2111;








var FunctionType = new Object(); 

FunctionType["AgentOpenServer"] = "1001";
FunctionType["AgentCloseServer"] = "1002";
FunctionType["AgentLogin"] = "1003";
FunctionType["AgentLogout"] = "1004";
FunctionType["AgentAvailable"] = "10002";
FunctionType["AgentNotReady"] = "10001";
FunctionType["AgentOtherWork"] = "1007";
FunctionType["AgentAfterCallWork"] = "10003";
FunctionType["AgentOperationEnd"] = "1009";
FunctionType["AgentSetStatus"] = "10004";
FunctionType["CallDial"] = "2001";
FunctionType["CallAnswer"] = "2002";
FunctionType["CallHangUp"] = "2003";
FunctionType["CallHoldOn"] = "2004";
FunctionType["CallHoldOff"] = "2005";
FunctionType["CallInitiateTransfer"] = "2006";
FunctionType["CallCompleteTransfer"] = "2007";
FunctionType["CallCancelTransfer"] = "2008";
FunctionType["CallInitiateConference"] = "2009";
FunctionType["CallCompleteConference"] = "2010";
FunctionType["CallCancelConference"] = "2011";
FunctionType["CallMuteOn"] = "2012";
FunctionType["CallMuteOff"] = "2013";
FunctionType["CallPlayDigits"] = "2014";
FunctionType["CallBlindTransfer"] = "2015";
FunctionType["CallBlindConference"] = "2016";
FunctionType["CallMonitor"] = "2017";
FunctionType["CallGetVoice"] = "2018";
FunctionType["CallDropVoice"] = "2019";
FunctionType["CallAddVoice"] = "2020";
FunctionType["CallTransferVDN"] = "2021";


FunctionType["OpenRecord"] = "3000";    	
FunctionType["RecStartRecord"] = "3001";    	
FunctionType["RecStopRecord"] = "3002";    	
FunctionType["RecSendRecord"] = "3003";    	
FunctionType["GetRecStateRecord"] = "3004";    	
FunctionType["GetPIDRecord"] = "3005";    	
FunctionType["GetPIDSplitRecord"] = "3006";    	
FunctionType["CloseRecord"] = "3007";    	





var ConsultDialTypeConstants = new Object(); 
ConsultDialTypeConstants["ccpConsultDialInternal"] = 1; 	
ConsultDialTypeConstants["ccpConsultDialExternal"] = 2; 	



var BeforeAgentState = -1; 
var AgentState = -1; 
var InboundFlg = true; 
var RecordIntervalFlg;
var RecordPID = "";
var RecordPIDCollection = new Array(); 



var CallDialParameters = new Object(); 
CallDialParameters["UserID"] = "";
CallDialParameters["ServiceId"] = 1;
CallDialParameters["ExternalRouteID"] = 0;
CallDialParameters["WrapWhenManualCallCleared"] = 1;


var ctmpCTILink_Def = new Object(); 
ctmpCTILink_Def["ctmpV_None"] = 0; 	
ctmpCTILink_Def["ctmpV_ASAI"] = 1; 	
ctmpCTILink_Def["ctmpV_Meridian"] = 2; 	
ctmpCTILink_Def["ctmpV_CSTA1"] = 3; 	
ctmpCTILink_Def["ctmpV_CSTA2"] = 4; 	
ctmpCTILink_Def["ctmpV_CSTA3"] = 5; 

var ctmpAgentMode_Def = new Object(); 
ctmpAgentMode_Def["ctmpV_AgentLogin"] = 0; 	
ctmpAgentMode_Def["ctmpV_AgentLogout"] = 1; 	
ctmpAgentMode_Def["ctmpV_AgentNotReady"] = 2; 	    
ctmpAgentMode_Def["ctmpV_AgentReady"] = 3; 	         
ctmpAgentMode_Def["ctmpV_AgentOtherWork"] = 4; 	     
ctmpAgentMode_Def["ctmpV_AgentAfterCallWork"] = 5;    

var ctmpSyncMode_Def = new Object(); 
ctmpSyncMode_Def["ctmpV_SYNC"] = 1; 	
ctmpSyncMode_Def["ctmpV_ASYNC"] = 2; 	
ctmpSyncMode_Def["ctmpV_ASYNC_EVENT"] = 3; 	


var ctmpWorkMode_Def = new Object(); 
ctmpWorkMode_Def["ctmp_AUX_WORK"] = 1; 	
ctmpWorkMode_Def["ctmp_AFTCAL_WK"] = 2; 
ctmpWorkMode_Def["ctmp_AUTO_IN"] = 3; 	    
ctmpWorkMode_Def["ctmp_MANUAL_IN"] = 4; 


var ctmpMaintenanceFilter_Def = new Object(); 
ctmpMaintenanceFilter_Def["ctmpES_Null"] = 0;
ctmpMaintenanceFilter_Def["ctmpES_Initiate"] = 1;
ctmpMaintenanceFilter_Def["ctmpES_Altering"] = 2;
ctmpMaintenanceFilter_Def["ctmpES_Connect"] = 3;
ctmpMaintenanceFilter_Def["ctmpES_Hold"] = 4;
ctmpMaintenanceFilter_Def["ctmpES_Queued"] = 5;
ctmpMaintenanceFilter_Def["ctmpES_Fail"] = 6;











//================= 变量 ==========================

var CTILink = ctmpCTILink_Def.ctmpV_ASAI; 
var Mode = ctmpSyncMode_Def.ctmpV_SYNC; 
var AgentData = "4000"; 
var AgentGroup = "4000"; 
var WorkMode = ctmpWorkMode_Def.ctmp_MANUAL_IN; 
var Returnsuccess = 0; 
var MyReturnsuccess = 0; 
var AnswerFlg = false; 

function CICGetCall()
{
	return {
		CallID:'',
		PreviousCallID: '',
		Start: false,
		Status:'',
		isDial: false,
		isAlerting: false,
		isAnswered: false,
		isHangup: false,
		isHold: false,
		isTransferConference: false,
		TransferConferenceID:'',
		TransferConference: false
	};
}
function InfobirdGetCall()
{
	return {
		CallID:'',
		Start: false,
		PreviousCallID: '',
		NextsCallID: '',
		Status:'',
		isDial: false,
		isAlerting: false,
		isAnswered: false,
		isHangup: false,
		isHold: false,
		isTransferConference: false,
		TransferConference: false

	};
}

var week = []; 
week[0] = 'Mon';
week[1] = 'Tue';
week[2] = 'Wed';
week[3] = 'Thu';
week[4] = 'Fri';
week[5] = 'Sat';
week[6] = 'Sun';




function GetSoftphoneAction(obj)
{
	if(CTI==CTIList[0])
	{
		obj = SoftphoneAction;
	}    
	if(CTI==CTIList[1])
	{
		obj = SoftphoneAction.AgentPannel;
	}
	if(CTI==CTIList[2])
	{
		obj = SoftphoneAction;
	}
	if(CTI==CTIList[3])
	{
		obj = SoftphoneAction.AvayaCCESoftPhone;
	}
	return obj;
}

function GetSoftphoneAgent(obj)
{
	obj = SoftphoneAction.Agent;
	return obj;
}
function GetSoftphoneCall(obj)
{
	obj = SoftphoneAction.Call;
	return obj;
}

function GetSoftphoneRecord(obj)
{
	obj = SoftphoneAction.Record;
}

function SetParameters(Parameter,Value)
{
	Parameter = Value;
}



